<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/common.jspf"%>
<script type="text/javascript" src="${ctx}/js/metals/parts/parts_deliverynote_add.js"></script>
<script type="text/javascript">
	$(".selectinfo").change(function(){
		var buyId=$(this).val();
		var that=$(this);
		$.getJSON(rootPath+"/parts/parts-deliverynote_choose.shtml","buyId="+buyId,function(data){
				$.each(data, function(i, item){
				  	$("#tbl tr").not(":first").remove();
				  	if(i==0){
				  		that.parent().prev().find("input").val(item.id);
						that.parent().next().find("input").val(item.metalsBom.materialCode);
						that.parent().next().next().find("input").val(item.metalsBom.name);
						that.parent().next().next().next().find("input").val(item.metalsBom.specifications);
						that.parent().next().next().next().next().find("input").val(item.metalsBom.unit);
						that.parent().next().next().next().next().next().find("input").val(item.number);
						that.parent().next().next().next().next().next().next().find("input").val(item.price);
						that.parent().next().next().next().next().next().next().next().find("input").val(item.total);
						that.parent().next().next().next().next().next().next().next().next().find("input").val(item.comment);
				  	}else{
				  		
				  		R = tbl.insertRow(tbl.rows.length);//新插入的行
						C = R.insertCell(0);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="id" id="item_no_1_" value="'+item.id+'">';
						C = R.insertCell(1);
						C.innerHTML = '<select name="buyId" id="bomid" class="form-control selectinfo" ><option value="'+item.buyId+'">'+item.buyId+'</option></select>';
						C = R.insertCell(2);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="materialCode" id="item_balance_up_1" value="'+item.metalsBom.materialCode+'">'; 
						C = R.insertCell(3);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="name" id="item_balance_down_1" value="'+item.metalsBom.name+'">';
						C = R.insertCell(4);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="specifications" id="item_balance_down_1" value="'+item.metalsBom.specifications+'">';
						C = R.insertCell(5);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="unit" id="item_balance_down_1" value="'+item.metalsBom.unit+'">';
						C = R.insertCell(6);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="number" id="item_balance_down_1" value="'+item.number+'">';
						C = R.insertCell(7);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="price" id="item_balance_down_1" value="'+item.price+'">';
						C = R.insertCell(8);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="total" id="item_balance_down_1" value="'+item.total+'">';
						C = R.insertCell(9);
						C.colSpan="2";
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="comment" id="item_balance_down_1" value="'+item.comment+'">';
				  		
				  	}		  	
				}); 					 
		});
	});
</script>
<style type="text/css">
.td {
	width: 9%;
	overflow: hidden;
	height: 15%;
	text-align: center
}

.form-control {
	position: abslute;
	top: 20%;
	right: 20%;
	float: right"
}

.input-text {
	width: 100%;
	height: 100%
}

.col-sm-3 {
	width: 15%;
	float: left;
}

.col-sm-9 {
	width: 85%;
	float: left;
}

label[class^="btn btn-default"] {
	margin-top: -4px;
}
</style>
</head>
<body>
	<div style='width: 100%; height: 300px; overflow-x: auto;'>
		<form id="form" name="form" class="form-horizontal" method="post"
			action="${ctx}/parts/parts_add.shtml">
		<section class="panel panel-default">
		<table border="1" style="margin: 0 auto;">
			<tr class="tr ">
				<td class="td">日期</td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
			</tr>
			<tr>
				<td class="td">序号</td>
				<td class="td">采购单号</td>
				<td class="td">物料编码</td>
				<td class="td">名称</td>
				<td class="td">规格型号</td>
				<td class="td">单位</td>
				<td class="td">数量</td>
				<td class="td">单价</td>
				<td class="td">金额</td>
				<td class="td" colspan="2">备注</td>
			</tr>
			<tr>
			<tbody id="tbl">
				<tr>
					<td><input type="text" class="form-control"
						readonly="readonly" name="id" value=""></td>
					<td>
						<select name="buyId" class="form-control selectinfo" >
								<option>选择</option>
								<c:forEach var="key" items="${purchaseRequest }">
									<option value="${key.buyId }">${key.buyId }</option>
								</c:forEach>
						</select>
					</td>
					<td><input type="text" class="form-control" name="materialCode"
						readonly="readonly" value=""></td>
					<td><input type="text" class="form-control" name="name"
						readonly="readonly" value=""></td>
					<td><input type="text" class="form-control" name="specifications"
						readonly="readonly" value=""></td>
					<td><input type="text" class="form-control" id="handleTime"
						readonly="readonly" name="unit" value=""></td>
					<td><input type="text" class="form-control"
						readonly="readonly" name="number" value=""></td>
					<td><input type="text" class="form-control"
						readonly="readonly" name="price" value=""></td>
					<td><input type="text" class="form-control" name="total"
						readonly="readonly" value=""></td>
					<td colspan="2"><input type="text" class="form-control"
						name="comment" readonly="readonly" value=""></td>
				</tr>
			</tbody>
			</tr>
			<tr>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td">会计</td>
				<td class="td">仓管员</td>
				<td class="td">送货人</td>
			</tr>
			<tr>
				<td class="td">&nbsp;</td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
			</tr>
			<tr>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td">日期</td>
				<td class="td">日期</td>
				<td class="td">日期</td>
			</tr>
			<tr>
				<td class="td">&nbsp;</td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
				<td class="td"></td>
			</tr>
		</table>
		<footer class="panel-footer text-right bg-light ">
				<button type="submit" class="btn btn-success btn-s-xs">提交</button>
			</footer>
		</section>
		</form>
	</div>
</body>
</html>